package com.xujie.sportsmeeting.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 系统公告响应VO
 */
@Data
@Schema(description = "系统公告响应信息")
public class SystemNoticeVO {

    @Schema(description = "公告ID")
    private Long id;

    @Schema(description = "公告标题")
    private String title;

    @Schema(description = "公告内容")
    private String content;

    @Schema(description = "公告类型")
    private Integer noticeType;

    @Schema(description = "公告类型描述")
    private String noticeTypeText;

    @Schema(description = "优先级")
    private Integer priority;

    @Schema(description = "优先级描述")
    private String priorityText;

    @Schema(description = "是否置顶")
    private Integer isTop;

    @Schema(description = "置顶状态描述")
    private String topText;

    @Schema(description = "发布状态")
    private Integer publishStatus;

    @Schema(description = "发布状态描述")
    private String publishStatusText;

    @Schema(description = "发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publishTime;

    @Schema(description = "过期时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime expireTime;

    @Schema(description = "发布人ID")
    private Long publisherId;

    @Schema(description = "发布人姓名")
    private String publisherName;

    @Schema(description = "状态 0-草稿 1-已发布 2-已下架")
    private Integer status;

    @Schema(description = "阅读次数")
    private Integer readCount;


    @Schema(description = "是否已阅读")
    private Boolean hasRead;

    @Schema(description = "是否已确认")
    private Boolean hasConfirmed;

    @Schema(description = "阅读时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime readTime;

    @Schema(description = "确认人数统计")
    private Long confirmCount;

    @Schema(description = "是否有效")
    private Boolean isValid;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    // 获取公告类型描述
    public String getNoticeTypeText() {
        if (noticeType == null) return "";
        switch (noticeType) {
            case 1: return "系统公告";
            case 2: return "比赛通知";
            case 3: return "成绩公布";
            case 4: return "紧急通知";
            default: return "未知类型";
        }
    }

    // 获取优先级描述
    public String getPriorityText() {
        if (priority == null) return "";
        switch (priority) {
            case 1: return "低";
            case 2: return "中";
            case 3: return "高";
            case 4: return "紧急";
            default: return "普通";
        }
    }

    // 获取置顶状态描述
    public String getTopText() {
        if (isTop == null) return "";
        return isTop == 1 ? "置顶" : "普通";
    }

    // 获取发布状态描述
    public String getPublishStatusText() {
        if (publishStatus == null) return "";
        switch (publishStatus) {
            case 0: return "草稿";
            case 1: return "已发布";
            case 2: return "已撤回";
            default: return "未知状态";
        }
    }


    // 获取优先级图标
    public String getPriorityIcon() {
        if (priority == null) return "";
        switch (priority) {
            case 1: return "🔵"; // 低
            case 2: return "🟡"; // 中
            case 3: return "🟠"; // 高
            case 4: return "🔴"; // 紧急
            default: return "⚪";
        }
    }

    // 获取类型图标
    public String getNoticeTypeIcon() {
        if (noticeType == null) return "";
        switch (noticeType) {
            case 1: return "📢"; // 系统公告
            case 2: return "🏃"; // 比赛通知
            case 3: return "🏆"; // 成绩公布
            case 4: return "⚠️"; // 紧急通知
            default: return "📝";
        }
    }
}
